package wang.unclecat.aar2jar
//https://www.jianshu.com/p/afa35b6a1098  如何实现provided AAR？如何实现Jar依赖AAR


class FileUtils {

  static File mkdirs(File folder) {
    // attempt to create first.
    // if failure only throw if folder does not exist.
    // This makes this method able to create the same folder(s) from different thread
    if (!folder.mkdirs() && !folder.isDirectory()) {
      throw new RuntimeException("Cannot create directory " + folder)
    }

    return folder
  }

  static File join(File dir, String paths) {
    return new File(dir, paths)
  }

  static void createParentDirs(File file) throws IOException {
    File parent = file.getCanonicalFile().getParentFile()
    if (parent == null) {
      /*
       * The given directory is a filesystem root. All zero of its ancestors exist. This doesn't
       * mean that the root itself exists -- consider x:\ on a Windows machine without such a drive
       * -- or even that the caller can create it, but this method makes no such guarantees even for
       * non-root files.
       */
      return
    }
    parent.mkdirs()
    if (!parent.isDirectory()) {
      throw new IOException("Unable to create parent directories of " + file)
    }
  }
}